package com.huawei.xme.ch02.t11;

import java.util.Arrays;

/**
 * @author 黄后林
 * @date 2022-10-26 11:01:29
 * @note 程序员是用代码喂出来的
 */
public class Task02 {

    public static void main(String[] args) {

        System.out.println(xx());


    }

    public static   int  xx(){
        int age=-1;
        for(int index =1; index<=100;index++) {
            age =index;
            if (b3(age)) {

                if (b4(age)) {

                    System.out.println(age);
                    int rs1 = age * age * age;
                    int rs2 = age * age * age * age;
                    System.out.println("rs1=" + rs1);
                    System.out.println("rs2=" + rs2);
                    boolean rs = check0to9(rs1, rs2);
                    if (rs) {
                        return age;
                    }

                }


            }
        }

        return -1;

    }

    public static  boolean check0to9(int rs1,int rs2){

        String rs = ""+rs1+rs2;
        int[] array =new int[10];
        for(int index =0; index<rs.length();index++){
            array[index]= Integer.parseInt(""+rs.charAt(index));
        }
        Arrays.sort(array);

        System.out.println(array);

        int sum =0;
        for(int index=1;index<=10;index++){
            sum = sum+index;
        }
        System.out.println("sum="+sum);

        if(sum ==55){
            return true;
        }



        return  false;

    }

    public static boolean b3(int age){
        int rs = age * age * age;
        if(rs>=1000 && rs<10000 ){
            return true;
        }
        return false;
    }

    public static boolean b4(int age){
        int rs = age * age * age* age;
        if(rs>=100000 && rs<1000000 ){
            return true;
        }
        return false;
    }


}
